feat: add env init command that copies from template placeholders#516
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #516 +/- ##
==========================================
+ Coverage 71.54% 71.64% +0.09%
==========================================
Files 224 225 +1
Lines 18959 19066 +107
==========================================
+ Hits 13565 13659 +94
- Misses 4193 4201 +8
- Partials 1201 1206 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mwbrooks
left a comment
There was a problem hiding this comment.
🙇🏻 Thanks a bunch for opening this PR! 🎉 I'm excited to see this one landing.
🧠 Could we swap "template placeholders" for "template file" or ".env template file"? "Placeholder" tends to imply a variable or token that gets substituted, which is a bit ambiguous here. Since we're copying the file verbatim, ".env template file" is more precise and the common convention in the wild from a little Claude research.
|
@mwbrooks Apologies for the pause after review 🎁 ✨ The polish to how these concepts landed above and I think it puts this in a better place for ongoing iteration! Let's not think about that right now though. I requested another review for sureness of how this appears 🔮 |
mwbrooks
left a comment
There was a problem hiding this comment.
✅ Thanks for the refactors @zimeg! This PR looks great and works like a charm! 👌🏻
🧪 Manual tests are looking good and unit tests have good test coverage.
📝 A few follow-ups that come to mind:
- suggestion: We should include
env initas part ofproject initso that the new projects come with a.envprovisioned out-of-the-box. - question: When no
.envexists and we runenv set, the CLI creates.env. Should it create a blank.envor use.env.example/samplewhen it exists? My first impression is that we'd remain consistent if we tempalted from the.env.example/sample.
| // Init copies an .env template file (.env.sample or .env.example) to .env. It | ||
| // returns an error if .env already exists, or if no template file is found. | ||
| func Init(fs afero.Fs) (string, error) { | ||
| sampleFiles := []string{".env.sample", ".env.example"} |
There was a problem hiding this comment.
note: I had Claude do some research on github.com and these are the top 2 placeholder names for .env files and make up the largest percentage. So, I think this is a great start!
There was a problem hiding this comment.
@mwbrooks Thanks for investigating too! IIRC our samples prefer .env.sample most and I'm willing to extend this as requested 🫡
| ErrDenoNotFound = "deno_not_found" | ||
| ErrDeployedAppNotSupported = "deployed_app_not_supported" | ||
| ErrDocumentationGenerationFailed = "documentation_generation_failed" | ||
| ErrDotEnvFileAlreadyExists = "dotenv_file_already_exists" |
There was a problem hiding this comment.
praise: error code prefixes for clean organization! 🎉
There was a problem hiding this comment.
@mwbrooks The prefix matches the package too! I hope we can continue this pattern as errors are wrapped across boundaries 🎁 ✨
|
@mwbrooks Super duper appreciate this being brought to the finish line! Thanks for sharing suggestions and feedback ahead 🏁 I like both ideas if this
Let's soon merge this for upcoming release I think! 🚢 💨 |
Changelog
Summary
This PR adds the
env initcommand that copies from template placeholders 🌲Preview
Included are expected cases and common edges to encounter! 🔬 ✨
⚡ Bolt Frameworks
🥀 ROSI Features
Testing
Checkout the changes of this branch and experiment with either a Bolt or Deno app:
Notes
Some follow up remains proposed to improve this but is left out of scope for this PR 🏁
project initought make setup a breeze it's been said 😉Requirements